package com.example.demo.common.domain;

import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;

@Data
@NoArgsConstructor
@AllArgsConstructor
public class CommonResult {
    private int status;
    private String error;
    private String desc;
    private Object data;

    public static CommonResult ok() {
        return ok("success", null);
    }

    public static CommonResult ok(String error, Object data) {
        return new CommonResult(0, error, "ok", data);
    }

    public static CommonResult ok(Object data) {
        return new CommonResult(0, "success", "ok", data);
    }

    public static CommonResult fail() {
        return fail("fail", "error");
    }

    public static CommonResult fail(String error, String desc) {
        return new CommonResult(400, error, desc, null);
    }

}
